import pathway as pw
from typing import Dict, Any, Optional

from application.db.mysql_db.info.ResourceInformationSectionList import ResourceInformationSectionList


class ResourceInformationSectionListSchema(pw.Schema):
    section_id: str
    information_id: str
    section_order: int
    section_attr: str
    title_level: int
    marc_code: Optional[str]
    src_text: Optional[Dict[str, Any]]
    dst_text: Optional[Dict[str, Any]]
    media_info: Optional[str]
    md5_encode: str
    is_del: int = pw.column_definition(default_value=0)


class ResourceInformationSectionListRead(pw.io.python.ConnectorSubject):

    def run(self):
        select_list = ResourceInformationSectionList.select().dicts()
        for doc in select_list:
            self.next(**doc)